package hibu.LeiJonGun.customViews;

import hibu.LeiJonGun.seniorservice.R;
import hibu.LeiJonGun.seniorservice.sizeType;
import android.content.Context;
import android.graphics.Canvas;
import android.view.ViewGroup;

/*
* Written by: Christian L. Gunvaldsen
* 
* This is used by CustomViewAssignment, CustomViewUser and CustomViewUserRequest
* to represent an assignment, user or user request in the application
*/
public abstract class CustomAbstractViewGroup extends ViewGroup {
	protected sizeType screenSize;
	protected int viewWidth;
	protected int viewHeight;
	protected int marginTopPx;
	protected int textSize;
	protected int padding;
	protected String username;
	protected int viewIdx;

	public CustomAbstractViewGroup(Context context) {
		super(context);
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		// TODO Auto-generated method stub
		
	}
	
	protected void getScreenSize() { // check screen size and get sizes for the view + text
		if (screenSize == sizeType.Small) { //Small
			marginTopPx = this.getResources().getDimensionPixelSize(R.dimen.lblUserSizeSmall);
			textSize = this.getResources().getDimensionPixelSize(R.dimen.lblTextSizeSmall);
			padding = this.getResources().getDimensionPixelSize(R.dimen.lblUserPaddingSmall);
		} else if (screenSize == sizeType.Medium) { //Medium
			marginTopPx = this.getResources().getDimensionPixelSize(R.dimen.lblUserSizeMedium);
			textSize = this.getResources().getDimensionPixelSize(R.dimen.lblTextSizeMedium);
			padding = this.getResources().getDimensionPixelSize(R.dimen.lblUserPaddingMedium);
		} else if (screenSize == sizeType.Large) { //Large
			marginTopPx = this.getResources().getDimensionPixelSize(R.dimen.lblUserSizeLarge);
			textSize = this.getResources().getDimensionPixelSize(R.dimen.lblTextSizeLarge);
			padding = this.getResources().getDimensionPixelSize(R.dimen.lblUserPaddingLarge);
		} else if (screenSize == sizeType.XLarge) { //XLarge
			marginTopPx = this.getResources().getDimensionPixelSize(R.dimen.lblUserSizeXLarge);
			textSize = this.getResources().getDimensionPixelSize(R.dimen.lblTextSizeXLarge);
			padding = this.getResources().getDimensionPixelSize(R.dimen.lblUserPaddingXLarge);
		}
	}
	
	protected void setPadding() {
		this.setPadding(padding,padding,0,0);
	}
	
	@Override
	public void onDraw(Canvas canvas)  { // draw the view (called from the system automatic)
		super.onDraw(canvas); 
	}
	
	protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) { // measure the view (called from the system automatic)
	    super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
	    viewWidth= MeasureSpec.getSize(widthMeasureSpec);
	    viewHeight = MeasureSpec.getSize(heightMeasureSpec);
	}
	
	public String getUsername() {
		return username;
	}

}
